home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / progut~1 / stdwin.zoo / h / string.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-29  |  4.0 KB  |  166 lines

  1. #ifndef __STDC__
  2. /* SYSV-compatible <string.h> */
  3. char *strcpy(), *strncpy();
  4. char *strchr(), *strrchr();
  5. int strcmp(), strncmp();
  6. char *strcat();
  7. #else
  8. /*
  9.  * String functions.
  10.  */
  11. #ifndef _STRING_H
  12. #define _STRING_H
  13.  
  14. #include <stddef.h>
  15.  
  16. #if ((defined(__STDC__)) && (!defined(__NO_PROTO__)))
  17.  
  18. void *    memcpy(void * dst, const void * src, size_t size);
  19. char *    strcpy(char *dst, const char *src);
  20. char *    strncpy(char *dst, const char *src, size_t size);
  21. char *    strcat(char *dst, const char *src);
  22. char *    strncat(char *dst, const char *src, size_t size);
  23. int     memcmp(const void * s1, const void * s2, size_t size);
  24. int     strcmp(const char *s1, const char *s2);
  25. int     strncmp(const char *s1, const char *s2, size_t size);
  26.      /* strcoll not implemented for now */
  27. size_t    strcoll(char *to, size_t maxsize, const char *from);
  28. void *     memchr(const void * s, int ucharwanted, size_t size);
  29. char *    strchr(const char *s, int charwanted);
  30. size_t     strcspn(const char *s, const char *reject);
  31. char *    strpbrk(const char *s, const char *breakat);
  32. char *    strrchr(const char *s, int charwanted);
  33. size_t     strspn(const char *s, const char *accept);
  34. char *    strstr(const char *s, const char *wanted);
  35. char *    strtok(char *s, const char *delim);
  36. void *     memset(void *s, int ucharfill, size_t size);
  37. size_t     strlen(const char *s);
  38. char *    strerror(int errnum);
  39.  
  40. #ifndef __STRICT_ANSI__
  41. /* 
  42.  * from henry spencers string lib
  43.  *  these dont appear in ansi draft sec 4.11
  44.  */
  45. void *    memccpy(void * dst, const void * src, int ucharstop, size_t size);
  46. char *    strlwr(char *);
  47. char *    strrev(char *);
  48. char *  strdup(const char *s);
  49.  
  50. /*
  51.  * V7 and BSD compatibility.
  52.  */
  53. char *    index(const char *s, int charwanted);
  54. char *    rindex(const char *s, int charwanted);
  55. void    bcopy(const void *src, void *dst, size_t length);
  56. int    bcmp(const void *s1, const void *s2, size_t length);
  57. void    bzero(void *dst, size_t length);
  58. #ifdef __MSHORT__
  59. void     lbcopy(const void *src, void *dst, long length);
  60. int    lbcmp(const void *s1, const void *s2, long length);
  61. void    lbzero(void *dst, long length);
  62. #endif /* __MSHORT__ */
  63. #endif /* __STRICT_ANSI__ */
  64.  
  65. #else /* not __STDC__ */
  66.  
  67. extern void *    memcpy();
  68. extern char *    strcpy();
  69. extern char *    strncpy();
  70. extern char *    strcat();
  71. extern char *    strncat();
  72.      /* strcoll not implemented for now */
  73. extern size_t     strcoll();
  74. extern void *    memchr();
  75. extern char *    strchr();
  76. extern size_t     strcspn();
  77. extern char *    strpbrk();
  78. extern char *    strrchr();
  79. extern size_t     strspn();
  80. extern char *    strstr();
  81. extern char *    strtok();
  82. extern void *    memset();
  83. extern size_t     strlen();
  84. extern char *    strerror();
  85.  
  86. #ifndef __STRICT_ANSI__
  87. /* 
  88.  * from henry spencers string lib
  89.  *   these dont appear in ansi draft sec 4.11
  90.  */
  91. extern void * memccpy();
  92. extern char *    strlwr();
  93. extern char *    strrev();
  94. extern char *   strdup();
  95.  
  96. /*
  97.  * V7 and BSD compatibility.
  98.  */
  99. extern char *    index();
  100. extern char *    rindex();
  101. extern void     bcopy();
  102. extern void    bzero();
  103. #ifdef __MSHORT__
  104. extern void     lbcopy();
  105. extern void    lbzero();
  106. #endif /* __MSHORT__ */
  107. #endif /* __STRICT_ANSI__ */
  108.  
  109. #endif /* __STDC__ */
  110.  
  111. #ifndef __STRICT_ANSI__
  112. #ifndef __MSHORT__
  113. #define lbcopy    bcopy
  114. #define lbcmp     bcmp
  115. #define lbzero    bzero
  116. #endif /* __MSHORT__ */
  117. #endif /* __STRICT_ANSI__ */
  118.  
  119. /* some macro versions of functions. these are faster, but less
  120.    forgiving of NULLs and similar nasties. to use the library functions,
  121.    just #undef the appropriate things.
  122. */
  123.  
  124. #if defined(__STDC__) && !defined(__NO_PROTO__)
  125. #if defined(__GNUC__) && !defined(__NO_INLINE__)
  126.  
  127. static inline
  128. char *
  129. __strcat(char *dst, const char *src)
  130. {
  131.     register char *dscan;
  132.  
  133.     for (dscan = dst; *dscan; dscan++) ;
  134.     while (*dscan++ = *src++) ;
  135.     return dst;
  136. }
  137.  
  138. static inline 
  139. char *
  140. __strcpy(char *dst, const char *src)
  141. {
  142.     register char *dscan = dst;
  143.     while (*dscan++ = *src++) ;
  144.     return dst;
  145. }
  146.  
  147. static inline
  148. size_t
  149. __strlen(const char *scan)
  150. {
  151.     register size_t count = 0;
  152.     while (*scan++) count++;
  153.     return count;
  154. }
  155.  
  156. #define strcat     __strcat
  157. #define strcpy     __strcpy
  158. #define strlen     __strlen
  159.  
  160. #endif /* __GNU__ && !__NO_INLINE__ */
  161. #endif /* __STDC__ && !__NO_PROTO__ */
  162.  
  163. #endif /* _STRING_H */
  164.  
  165. #endif
  166.